/*
 * Copyright 2009 Prime Technology.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.primefaces.optimus.application;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

import javax.faces.context.FacesContext;

/**
 * Default implementation of FacesMessages, uses FacesContext access session map
 */
public class SessionImpl implements Session {

	private Map<String,Object> wrappedMap;
	
	public SessionImpl() {
		this.wrappedMap = FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
	}

	public void clear() {
		wrappedMap.clear();
	}

	public boolean containsKey(Object key) {
		return wrappedMap.containsKey(key);
	}

	public boolean containsValue(Object value) {
		return wrappedMap.containsValue(value);
	}

	public Set<java.util.Map.Entry<String, Object>> entrySet() {
		return wrappedMap.entrySet();
	}

	public Object get(Object key) {
		return wrappedMap.get(key);
	}

	public boolean isEmpty() {
		return wrappedMap.isEmpty();
	}

	public Set<String> keySet() {
		return wrappedMap.keySet();
	}

	public Object put(String key, Object value) {
		return wrappedMap.put(key, value);
	}

	public void putAll(Map<? extends String, ? extends Object> T) {
		wrappedMap.putAll(T);
	}

	public Object remove(Object key) {
		return wrappedMap.remove(key);
	}

	public int size() {
		return wrappedMap.size();
	}

	public Collection<Object> values() {
		return wrappedMap.values();
	}
}
